<template>
  <div class="dataThree" ref="dataThree">柱状图3333</div>
</template>

<script>
import * as echarts from 'echarts'
import { kefuDataNetwork } from '@/network/networks'
export default {

  props: {
    pullTime: Array
  },
  data () {
    return {
      krfu: [],
      num: []

    }
  },
  methods: {
    getFenBu () {
      kefuDataNetwork(this.pullTime).then(res => {
        this.kefu = res.data.kefu
        this.num = res.data.num
        this.initEcharts()
      })
    },
    initEcharts () {
      const myChart = echarts.init(this.$refs.dataThree)

      const option = {
        title: {
          text: '客服录入量统计',
          left: 'center'
        },
        color: ['pink'],
        tooltip: {
          trigger: 'axis',
          axisPointer: { // 坐标轴指示器，坐标轴触发有效
            type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: [
          {
            type: 'category',
            data: this.kefu,
            axisTick: {
              alignWithLabel: true
            }
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '直接访问',
            type: 'bar',
            barWidth: '60%',
            data: this.num
          }
        ]
      }

      myChart.setOption(option)
    }
  },
  mounted () {
    this.getFenBu()
  },
  watch: {
    pullTime (val) {
      this.getFenBu()
    }

  }
}
</script>

<style lang="less" scoped>
.dataThree {
  width: 100%;
  height: 600px;
}
</style>
